package com.ea.eadp.nexus.test.pageDefinition.newconsole;

import org.openqa.selenium.WebDriver;
import org.testng.Assert;


public class CreateOriginAccountPage extends ConsoleBasePage {
    public final static String passwordInputBox = "password";
    public final static String confirmPasswordInputBox = "confirmPassword";
    public final static String originIdInputBox = "originId";

    public CreateOriginAccountPage(WebDriver driver) {
        super(driver, CreateOriginAccountPage.class, passwordInputBox);
    }

    public void enterPassword(String password) {
        log.info("Enter Password:" + password);
        sendInput(passwordInputBox, password);
        clickBlank("//div[@id='panel-basic']//span[@class='title']");
    }

    public void validatePassword(String password, String errorMessage) {
        log.info("Validate Password:" + password);
        sendInput(passwordInputBox, password);
        clickBlank("//div[@id='panel-basic']//span[@class='title']");
        Assert.assertEquals(getPasswordInvalidError(), errorMessage, "Input not trigger the correct error message");
    }

    public void enterConfirmPassword(String password) {
        log.info("Enter Confirm Password:" + password);
        sendInput(confirmPasswordInputBox, password);
        clickBlank("//div[@id='panel-basic']//span[@class='title']");
    }

    public void validateConfirmPassword(String password, String errorMessage) {
        log.info("Validate Confirm Password:" + password);
        sendInput(confirmPasswordInputBox, password);
        clickBlank("//div[@id='panel-basic']//span[@class='title']");
        Assert.assertEquals(getConfirmPasswordInvalidError(), errorMessage, "Input not trigger the correct error message");
    }

    public void enterOriginId(String originId) {
        log.info("Enter Origin Id:" + originId);
        sendInput(originIdInputBox, originId);
        clickBlank("//div[@id='panel-basic']//span[@class='title']");
        sendControllerKey('A');
    }

    public void validateOriginId(String originId, String errorMessage) {
        log.info("Validate Origin Id:" + originId);
        sendInput(originIdInputBox, originId);
        clickBlank("//div[@id='panel-basic']//span[@class='title']");
        Assert.assertEquals(getOriginIdInvalidError(), errorMessage, "Input not trigger the correct error message");
    }

    public String getTitle() {
        return getElementStringByXPath("//div[@id='panel-basic']//span[@class='title']");
    }

    public String getEmailLabel() {
        return getElementStringByXPath("//div[@id='panel-basic']//li[1]/span[@class='title']");
    }

    public String getEmailText() {
        return getElementStringByXPath("//div[@id='panel-basic']//li[1]/span[@class='emailText']");
    }

    public String getPasswordLabel() {
        return getElementStringByXPath("//li[@id='password-container']//label[@class='origin-ux-textbox-label']");
    }

    public String getPasswordTip() {
        return getElementStringByXPath("//li[@id='password-container']//span[@class='origin-ux-tooltip-message-large']");
    }

    public String getPasswordInvalidError() {
        return getElementStringByXPath("//li[@id='password-container']//span[@class='origin-ux-textbox-status-message origin-ux-status-message']");
    }

    public String getConfirmPasswordLabel() {
        return getElementStringByXPath("//li[@id='confirm-password-container']//label[@class='origin-ux-textbox-label']");
    }

    public String getConfirmPasswordInvalidError() {
        return getElementStringByXPath("//li[@id='confirm-password-container']//span[@class='origin-ux-textbox-status-message origin-ux-status-message']");
    }

    public String getOriginIdLabel() {
        return getElementStringByXPath("//li[@id='origin-id-container']//label[@class='origin-ux-textbox-label']");
    }

    public String getOriginIdTip() {
        return getElementStringByXPath("//li[@id='origin-id-container']//span[@class='origin-ux-tooltip-message-large']");
    }

    public String getOriginIdInvalidError() {
        return getElementStringByXPath("//li[@id='origin-id-container']//span[@class='origin-ux-textbox-status-message origin-ux-status-message']");
    }
}